<template>
    <BasicModal v-bind="$attrs" @register="register" :title="getTitle" @ok="submitAudit">
        <a-form ref="formRef" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }" :model="fdata" :rules="validatorRules">
            <a-row>
                <a-col :span="24">
                    <a-form-item label="题库名称" name="bId">
                        <j-dict-select-tag v-model:value="fdata.bId" dictCode="lab_exam_bank,name,id"
                            :show-choose-option="false" />
                    </a-form-item>
                </a-col>
            </a-row>
        </a-form>
    </BasicModal>
</template>
  
<script lang="ts" setup>
import { BasicModal, useModalInner } from '/@/components/Modal';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { addOrDelBank } from './LabExamQuestion.api';
import { ref, reactive } from 'vue';

const getTitle = ref('');
const fdata = reactive({
    bId: "",
    oper: "",
    ids: "",
});

function reset() {
    fdata.bId = '';
    fdata.oper = '';
    fdata.ids = '';
}

const validatorRules = {
    bId: [{ required: true, message: '请选择题库名称!' },],
};
const [register, { setModalProps,closeModal }] = useModalInner((data) => {
    setModalProps({
        minHeight: 150
    });
    reset();
    fdata.ids = data.ids;
    fdata.oper = data.oper;
    if (fdata.oper == 'add') {
        getTitle.value = '加入题库';
    } else {
        getTitle.value = '移除题库';
    }
});

async function submitAudit() {
    if (fdata.oper == 'add') {
        await addOrDelBank(fdata);
        closeModal();
    } else {
        await addOrDelBank(fdata);
        closeModal();
    }
}


</script>
  
<style scoped></style>